<%-- 
    Document   : bodysanpham
    Created on : 28-09-2011, 09:47:39
    Author     : Mr-Nguyen
--%>
<%@page import="DAO.sanphamDAO"%>
<%@page import="DatabasePOJO.sanpham"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%
    ArrayList<sanpham> arrsp  = null;
    if(request.getParameter("MaSanPham") != null){
        String ma = request.getParameter("MaSanPham");
        arrsp = new ArrayList<sanpham>();
        arrsp.add(sanphamDAO.getSanPham(ma));
        session.setAttribute("ctsp", arrsp);
    }
    if(request.getParameter("maLinhVuc") != null){
        String mavl = request.getParameter("maLinhVuc");
        arrsp = sanphamDAO.getListSanPham("where maLinhVuc =" + mavl);
        if(arrsp.size() == 0)
            request.setAttribute("message", "true");
    } 
    if(arrsp != null && arrsp.size() != 0)
       session.setAttribute("sp", arrsp);     
    else{
        arrsp = sanphamDAO.getListSanPham("");
        session.setAttribute("sp", arrsp);
    }
    if(arrsp.size() == 0)
        return;
 
%>
 <table width="100%" height="100%" border="0">
      <tr>
        <td width="74%" height="500" valign="top">
    <table width="100%" height="100%" border="0">
          <tr>
            <td height="300" valign="top">
            <table width="100%" height="380" border="0">
              <tr>
                  <td height="71" colspan="2" background="Images/backngang.gif">
                      <a href="index.jsp?Action=chitiet&MaSanPham=<%= arrsp.get(0).getMaSanPham() %>"><%= arrsp.get(0).getTitle() %></a>
                  </td>
                </tr>
              <tr>
                <td width="62%" height="250">
                    <a href="index.jsp?Action=chitiet&MaSanPham=<%= arrsp.get(0).getMaSanPham() %>"> <img src="Images/<%= arrsp.get(0).getHinhDaiDien() %>" width="100%" height="300px"/></a>
                </td>
                <td width="38%" valign="top">
                <table width="100%" height="300px" border="0" background="Images/backtable.gif">
                  <tr>
                      <td height="50px" colspan="2" style="background-repeat: no-repeat; background-position: center" background="Images/buy.png">
                  <center><b><%= arrsp.get(0).getGiaKhuyenMai() %></b>VNĐ
                      <a href="index.jsp?Action=Mua&MaspMua=<%= arrsp.get(0).getMaSanPham() %>">  <img src="Images/muato.png" width="65" height="30" /></a>
                  </center>
                      </td>
                    </tr>
                   <tr>
                       <td height="51" style="text-decoration: line-through;" background="Images/backlogo.gif"><center><%= arrsp.get(0).getGiaBan() %>VNĐ </center></td>
                      <td background="Images/backlogo.gif"><center> <%= Integer.parseInt(arrsp.get(0).getGiaBan()) - Integer.parseInt(arrsp.get(0).getGiaKhuyenMai())  %>VNĐ</center></td>
                  </tr>
                  <tr>
                    <td height="59" colspan="2" background="Images/backngang.gif">
                        <center><b><%= arrsp.get(0).getLuotMua() %> Lược mua</b></center>
                    </td>
                    </tr>
                  <tr>
                      <td height="89" colspan="2" >
                          <jsp:include page="tinhthoigian.jsp" >
                              <jsp:param name="ngay" value="<%= arrsp.get(0).getNgayHetHang() %>"/>
                          </jsp:include>
                      </td>
                    <!--<td height="89" colspan="2">Thời gian còn lại</td>-->
                    </tr>
                </table></td>
              </tr>
            </table></td>
          </tr>
          <!-- Lập lại cho các sản phảm-->
          <tr>
            <td height="10">&nbsp;</td>
          </tr>
          <tr>
              <td height="105" valign="top"> &nbsp;
                <%
                if(request.getParameter("Action")!= null && request.getParameter("Action").equals("chitiet")==true){
                %>
                    <jsp:include page="chitietsanpham.jsp"/>
                <%}
                else {%>
                    <jsp:include page="dsSanpham.jsp"/> 
                <%}%>
            </td>
          </tr>
        </table>
  </td>
 </tr>
  <tr>
    <td height="50">&nbsp;</td>
  </tr>
</table>